#pragma once

#include <stdio.h>
#include "IStream.h"

NAMESPACE_CORE_BEGIN

class CORE_API CSimpleFileStream : public IOStream
{
private:
	CSimpleFileStream();
public:
	CSimpleFileStream(const char_x * szFile, StreamMode streamMode = StreamModeRead);
	~CSimpleFileStream();

public:
	bool CanRead() const;
	bool CanWrite() const;

	bool SeekSurpport(StreamSeek seek) const;
	int_x Seek(StreamSeek seek, int_x iSeek = 0);

	int_x ReadAviliable();
	byte_t ReadByte();
	void ReadByteArray(byte_t * pBytes, int_x iLength);

	int_x WriteAviliable();
	void WriteByte(byte_t byte);
	void WriteByteArray(const byte_t * pBytes, int_x iLength);
	void Flush();
public:
	int_x GetCurr();
	int_x GetFileSize();
	void Close();

private:
	void ConfirmFile() const;
protected:
	FILE * m_pFile;
	StreamMode m_streamMode;
};

NAMESPACE_CORE_END